<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>点谁谁怀孕</title>
    <style>
        div{
            width: 200px;
            height: 200px;
            border: 1px solid black;
            border-radius: 8px;
            float: left;
            margin-right: 20px;
            font-size: 20px;
            color: gold;
            text-align: center;
            line-height: 200px;
            cursor: pointer;
        }
    </style>
</head>
<body>
    <div id="box1"></div>
    <div id="box2"></div>
    <div id="box3"></div>
    <script>
        var box1=document.getElementById('box1')
        var box2=document.getElementById('box2')
        var box3=document.getElementById('box3')
        function huaiyu(){
            this.style.background='red';
            this.innerHTML='我怀孕了'
            var that=this;
            setTimeout(function (){
                that.innerHTML='你被绿了';
                that.style.background='green';
                setTimeout(function(){
                    that.innerHTML='悲伤逆流成河';
                    that.style.background='url(images/pan.jpg)'
                    that.style.backgroundSize= '200px 200px'; 
                },1000)
            } ,2000)
        }
         box1.onclick=huaiyu;
         box2.onclick=huaiyu;
         box3.onclick=huaiyu;
    
    </script>
</body>
</html>